/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.bld.util.facade;

import br.com.bld.util.conexao.ConexaoPGSQL;
import java.sql.Connection;
import java.sql.SQLException;

/**
 *
 * @author Pedro
 */
public abstract class AbstractBe {

    private final Boolean isConexaoExterna;
    public final Connection conn;

    public AbstractBe() throws SQLException {
        this.isConexaoExterna = false;
        this.conn = ConexaoPGSQL.getConection();
    }

    public AbstractBe(Connection conn) {
        this.isConexaoExterna = true;
        this.conn = conn;
    }

    public void commit() throws SQLException {
        if (!isConexaoExterna) {
            conn.commit();
        }
    }

    public void rollback() throws SQLException {
        if (!isConexaoExterna) {
            conn.rollback();
        }
    }

    public void close() throws SQLException {
        if (!isConexaoExterna) {
            conn.close();
        }
    }
    
}
